function p = splitimage_EMP_ComKernel(input1,input2,input3,input4,input5,...
    train1,train2,train3,train4,train5,w,scale1,scale2,scale3,scale4,scale5,...
    sigma1,sigma2,sigma3,sigma4,sigma5)

% x -> spectral vectors
% save classes
% y=x(2,:);

% delete first two (pixel number and classes)
% x(1:2,:)=[];


[d,n] =size(input1);
ntrain1 = sum(train1.^2);
ntrain2 = sum(train2.^2);
ntrain3 = sum(train3.^2);
ntrain4 = sum(train4.^2);
ntrain5 = sum(train5.^2);
n1 = floor(n/80);
p = [];
for i = 1:79
    x1 = input1(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain1);
    dist1 = Z1-2*train1'*x1+X1;
    K1=exp(-dist1/2/scale1/sigma1^2);
    
    x1 = input2(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain2);
    dist1 = Z1-2*train2'*x1+X1;
    K2=exp(-dist1/2/scale2/sigma2^2);
    
        x1 = input3(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain3);
    dist1 = Z1-2*train3'*x1+X1;
    K3=exp(-dist1/2/scale3/sigma3^2);
    
        x1 = input4(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain4);
    dist1 = Z1-2*train4'*x1+X1;
    K4=exp(-dist1/2/scale4/sigma4^2);
    
        x1 = input5(:,((i-1)*n1+1):n1*i);
    nx1 = sum(x1.^2);
    [X1,Z1] = meshgrid(nx1,ntrain5);
    dist1 = Z1-2*train5'*x1+X1;
    K5=exp(-dist1/2/scale5/sigma5^2);
    
    
    K1 = [ones(1,n1); K1;K2;K3;K4;K5 ];
%  K1 = [ones(1,n1); 0.4*K1+0.6*K2];
    p1=mlogistic(w,K1);
    p = [p p1];
%     x(:,1:n1) = [];
end

x1 = input1(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain1);
dist1 = Z1-2*train1'*x1+X1;
K1=exp(-dist1/2/scale1/sigma1^2);

x1 = input2(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain2);
dist1 = Z1-2*train2'*x1+X1;
K2=exp(-dist1/2/scale2/sigma2^2);

x1 = input3(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain3);
dist1 = Z1-2*train3'*x1+X1;
K3=exp(-dist1/2/scale3/sigma3^2);

x1 = input4(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain4);
dist1 = Z1-2*train4'*x1+X1;
K4=exp(-dist1/2/scale4/sigma4^2);


x1 = input2(:,(79*n1+1):n);
nx1 = sum(x1.^2);
[X1,Z1] = meshgrid(nx1,ntrain5);
dist1 = Z1-2*train5'*x1+X1;
K5=exp(-dist1/2/scale5/sigma5^2);

%     K = gamma*K1+(1-gamma)*K2;
K1 = [ones(1,n-79*n1); K1;K2;K3;K4;K5];
% K1 = [ones(1,n-79*n1); 0.4*K1+0.6*K2];
    
p1=mlogistic(w,K1);
p = [p p1];